Skip to content

slippage protection to the tip entrypoint added - #1430

Open
smith961 wants to merge 2 commits into
Akanimoh12:test-implement-dripsfrom
smith961:Add-slippage-protection-to-the-tip-entrypoint
Open

slippage protection to the tip entrypoint added#1430
smith961 wants to merge 2 commits into
Akanimoh12:test-implement-dripsfrom
smith961:Add-slippage-protection-to-the-tip-entrypoint

Conversation

@smith961

Copy link
Copy Markdown

Description

If min-tip or fee config changes between a user signing a tip and the transaction landing, the on-chain outcome can differ from what the UI showed. send_tip now accepts optional expected_min_tip and expected_fee_bps so callers can pin those values. A mismatch returns ConfigMismatch before any storage mutation or event. Passing None for both skips the checks and preserves prior tip behaviour.

Closes #1165

Type of Change

Please mark the options that are relevant:

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🧪 Tests (adding new tests or updating existing tests)
  • 📝 Documentation (changes to documentation/configs only)
  • 🚀 DevOps & CI/CD (changes to workflows, scripts, or templates)

Changes Made

  • contracts/tipz/src/lib.rs, tips.rs: send_tip takes optional expected_min_tip / expected_fee_bps; mismatch aborts with ConfigMismatch before TTL, rate-limit, transfer, or events.
  • contracts/tipz/src/errors.rs: add ConfigMismatch = 50 (Soroban error-enum cap is 50; RefundRequestExpired is now an alias of InvalidInput).
  • contracts/tipz/src/subscription.rs: recurring tips pass None/None so existing behaviour is unchanged.
  • contracts/tipz/src/test/test_tip_expectations.rs: tests for matching pins, mismatched min, mismatched fee, and omitted params.
  • frontend-scaffold/src/hooks/useContract.ts: sendTip encodes the new optional args (defaults to None).

How to Test

  1. From contracts/tipz, run: cargo test tip_expectations -- --test-threads=1
  2. Confirm these four tests pass:
    • test_send_tip_matching_expectations
    • test_send_tip_mismatched_min_tip
    • test_send_tip_mismatched_fee_bps
    • test_send_tip_omitted_expectations
  3. Optionally send a tip with None/None and confirm it still credits the creator as before. Send again with a stale expected_min_tip or expected_fee_bps and confirm ConfigMismatch with no balance or event change.

Checklist

💻 Smart Contract Changes (if applicable)

  • Running cargo fmt -- --check passes successfully.
  • Running cargo clippy -- -D warnings runs without any warnings.
  • All tests pass successfully using cargo test.
  • New unit or integration tests have been written to cover the changes.
  • No hardcoded values are present (e.g. addresses, fees) that should be configurable.

🎨 Frontend Changes (if applicable)

  • TypeScript compiles cleanly with no errors (npm run typecheck or npx tsc --noEmit).
  • Running npm run lint shows no linting errors.
  • The production build compiles successfully via npm run build.
  • Changes verified on local browser environment with Freighter/xBull/Albedo wallet.
  • Responsive design verified (tested on mobile, tablet, and desktop viewport sizes).
  • Keyboard navigation and accessibility (a11y) considerations are addressed.

⚙️ General

  • Code follows the project's coding standards and structure guidelines.
  • Self-reviewed the changes to ensure clean code with no commented-out code blocks.
  • No console.log or debug code remains in production files.
  • The branch is up-to-date with the main branch.

Screenshots / Demos (if applicable)

N/A — contract ABI / logic change only.

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@smith961 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Akanimoh12

Copy link
Copy Markdown
Owner

Please resolve the conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add slippage protection to the tip entrypoint

2 participants